﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace UniRx.Examples
{
	// Token: 0x020001E3 RID: 483
	public class Sample01_ObservableWWW : MonoBehaviour
	{
		// Token: 0x06000A1E RID: 2590 RVA: 0x000368A8 File Offset: 0x00034CA8
		private void Start()
		{
			ObservableWWW.Get("http://google.co.jp/", null, null).Subscribe(delegate(string x)
			{
				Debug.Log(x.Substring(0, 100));
			}, delegate(Exception ex)
			{
				Debug.LogException(ex);
			});
			var source = from google in ObservableWWW.Get("http://google.com/", null, null)
			from bing in ObservableWWW.Get("http://bing.com/", null, null)
			select new
			{
				google,
				bing
			};
			//IDisposable disposable = source.Subscribe(delegate(x)
			//{
			//	Debug.Log(x.google.Substring(0, 100) + ":" + x.bing.Substring(0, 100));
			//});
			//disposable.Dispose();
			IObservable<string[]> source2 = Observable.WhenAll<string>(new IObservable<string>[]
			{
				ObservableWWW.Get("http://google.com/", null, null),
				ObservableWWW.Get("http://bing.com/", null, null),
				ObservableWWW.Get("http://unity3d.com/", null, null)
			});
			source2.Subscribe(delegate(string[] xs)
			{
				Debug.Log(xs[0].Substring(0, 100));
				Debug.Log(xs[1].Substring(0, 100));
				Debug.Log(xs[2].Substring(0, 100));
			});
			ScheduledNotifier<float> scheduledNotifier = new ScheduledNotifier<float>();
			//scheduledNotifier.Subscribe(delegate(float x)
			//{
			//	Debug.Log(x);
			//});
			//string url = "http://google.com/";
			//ScheduledNotifier<float> progress = scheduledNotifier;
			//ObservableWWW.Get(url, null, progress).Subscribe<string>();
			ObservableWWW.Get("http://www.google.com/404", null, null).CatchIgnore(delegate(WWWErrorException ex)
			{
				Debug.Log(ex.RawErrorMessage);
				if (ex.HasResponse)
				{
					Debug.Log(ex.StatusCode);
				}
				foreach (KeyValuePair<string, string> keyValuePair in ex.ResponseHeaders)
				{
					Debug.Log(keyValuePair.Key + ":" + keyValuePair.Value);
				}
			}).Subscribe<string>();
		}
	}
}
